//package com.dykj.fireFighting.web.mq.consumer.business;
//
//import com.alibaba.fastjson.JSON;
//import com.dykj.fireFighting.api.base.appNotification.PushModel;
//import com.dykj.fireFighting.api.base.push.service.PushService;
//import com.dykj.fireFighting.common.core.constant.WebsocketConstant;
//import com.dykj.fireFighting.web.base.websocket.entity.MoreMessage;
//import com.dykj.fireFighting.web.model.Device;
//import com.dykj.fireFighting.web.model.vo.MqMessage;
//import com.dykj.fireFighting.web.utils.SpringUtil;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.common.message.Message;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * @Author fgc
// * @Date 2021/9/30 10:12
// * @ Description：MQ消息业务处理--设备运行记录入库
// */
//public class WaterAppPush extends BusinessProcess{
//    public static final Logger LOGGER = LoggerFactory.getLogger(WaterAppPush.class);
//    private static PushService pushService=(PushService)SpringUtil.getBean("pushService");
//    public WaterAppPush(){
//        super();
//    }
//    @Override
//    public ConsumeConcurrentlyStatus process(Message msg){
//        LOGGER.info("进入app推送业务实现");
//        String msgBody= null;
//        String key=msg.getKeys();
//        try {
//            msgBody = new String (msg.getBody(),"utf-8");
//            System.out.println(msgBody);
//            MqMessage mqMessage = JSON.parseObject(msgBody, MqMessage.class);
//            Device device = mqMessage.getDevice();
//            String time = mqMessage.getAlarmTime().substring(11);
//            PushModel pushModel=new PushModel();
//            switch (device.getStatus()){
//                case "液位低限预警":
//                    pushModel.setTitle("液位低限预警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"上报压力为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    break;
//                case "压力低限预警":
//                    pushModel.setTitle("压力低限预警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"上报压力为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    break;
//                case "液位高限报警":
//                    pushModel.setTitle("液位高限报警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"上报液位为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    break;
//                case "压力高限报警":
//                    pushModel.setTitle("液位低限预警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"上报压力为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    pushModel.setAlias(mqMessage.getUnit().getUnitId());
//                    break;
//                case "液位恢复":
//                    pushModel.setTitle("液位低限预警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"液位已恢复;当前液位为："+device.getCalculationValue());
//                    break;
//                case "压力恢复":
//                    pushModel.setTitle("液位低限预警通知");
//                    pushModel.setBody(device.getName()+"设备于今天"+time+"压力已恢复;当前液位为："+device.getCalculationValue());
//                    break;
//                }
//                pushModel.setAlias(mqMessage.getUnit().getUnitId());
//                pushModel.setClickType("none");
//                boolean b = pushService.pushAlias(pushModel);
//                System.out.println("===============================================================app推送结果："+b);
//                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//            } catch (UnsupportedEncodingException e) {
//                e.printStackTrace();
//                return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//            }
//
//    }
//
//}
